<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/login.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/HttpUtil.js"></script>
    <script src="js/CacheUtil.js"></script>

</head>
<body>
    <nav class="navbar navbar-default navbar-inverse navbar-static-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <a href="#" class="navbar-brand" style="color: #ffffff;"><i class="fa fa-sign-language"></i>阳光公寓</a>
            </div>
            <p class="navbar-text navbar-right login-text">
                <a href="register.html">注册</a>
            </p>
        </div>
    </nav>
    <div class="container">
        <div class="row">
            <div class="col-xs-6 col-xs-push-3">
                <div class="panel panel-danger login-panel">
                    <div class="panel-heading">
                        <!-- 面板的头部内容 -->
                        <h3 class="panel-title">用户登录</h3>
                    </div>
                    <div class="panel-body">
                        <form>
                            <div class="form-group">
                                <label for="username">用户名</label>
                                <input type="text" class="form-control"  id="username">
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input type="password" class="form-control"  id="password">
                            </div>
                            <div class="form-group">
                                <input onclick="userLogin()" type="button" value="登录"class="btn btn-danger btn-block"/>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
   /**
    * 管理员请求登录的方法
    * */
    function userLogin() {
       //ajax 请求后台登录校验
       let url = "/tUser/login";

       let params = {
           username: $("#username").val(),
           password: $("#password").val()
       };
       //这里调用实现ajax请求的方法
       httpPost(url,params,function (data) {
           //如果成功登录
           //则将用户名 存储到localStorage
           saveLoginUser(data);

            location.href="http://localhost:8080/gs/index.html";

        })

   }
</script>
</html>